package com.rebate.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rebate.model.Menu;
import com.rebate.service.IBaseService;


@Controller
public class MenuServlet {
	
	private String adminView = "/index";
	@Autowired
	private IBaseService<Menu> menuService;
	
	/**
	 * 猎取后台操作菜单
	 * @throws IOException 
	 */
	@RequestMapping(value = "/index.htm")
	public String getMenu(HttpServletRequest request,ModelMap model,
			HttpServletResponse response,@ModelAttribute("menu") Menu menu) throws IOException {
		List<Menu> list = menuService.findBySelective(null);
		if (list != null && list.size() > 0) {
			model.put("menuList", list);
		}
		return adminView;
	}
}
